package com.linchong.concurrency.chapter3;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * @Author:linchong
 * @CreateTime:2020-01-01 23:23
 * @Description:
 */
@Slf4j
public class CreateThread2 {
	public static void main(String[] args) {
		Thread t = new Thread() {
			@Override
			public void run() {
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		t.start();
//		log.info(t.getThreadGroup()+"");
//		log.info(Thread.currentThread().getName());
//		log.info(Thread.currentThread().getThreadGroup().getName());
		ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
		log.info(threadGroup.activeCount() + "");
		Thread[] threads = new Thread[threadGroup.activeCount()];
		threadGroup.enumerate(threads);
		Arrays.stream(threads).forEach(System.out::println);
		//Thread[Monitor Ctrl-Break,5,main]
		//三个线程，Monitor Ctrl-Break，可以捕获一些时间，如退格，关闭程序等


	}
}
